#ifndef COMMON_H
#define COMMON_H 1

#include <glib.h>
#include <ncurses.h>
#include <panel.h>

typedef struct {
	gchar *server;
	gchar *username;
	gchar *password;
	gboolean use_ssl;
} CopticAccount;

typedef struct {
	guint max_rows;
	GPtrArray *rows;
} TextBuffer;


typedef struct {
	WINDOW *ncwin;
	TextBuffer *buffer;
} CopticWindow;

typedef struct {
	gchar *module_name;

	  gboolean(*connect) (CopticAccount *);
	  gboolean(*disconnect) (CopticAccount *);
	  gboolean(*start_conversation) (CopticAccount *, gchar *);
	  gboolean(*close_conversation) (CopticAccount *, gchar *);
	  gboolean(*set_personal_message) (CopticAccount *, gchar *);
	  gboolean(*set_status) (CopticAccount *, gint);
} CopticModule;


/* Interface.c */

void destroy_interface();
void init_interface();
void draw_interface();
void redraw_interface();

int has_resized();
int has_quit();
int get_max_y();
int get_max_x();

/* Contactlist.c */
void set_contact_list_width(int);
int get_contact_list_width();
void draw_contact_list();
void destroy_contact_list();
void add_category(gchar *);
void add_item(guint, gchar *, int);


/* Utf8.c */
wchar_t *wchar_from_utf8(const gchar *, wchar_t *, gsize);

/* Textwrap.c */

TextBuffer *textBuffer_new(guint);
gint textBuffer_add(TextBuffer *, gchar *, guint);
gchar *textBuffer_get_index(TextBuffer *, guint);


/* Signal.c */
void setup_signal_handler();

/* Keyfile.c */
gint keyfile_read();
GKeyFile *keyfile_get();

/* Regproto.c */
void regproto_init();
void regproto_add(CopticModule *);


#endif
